#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>

int port = 9000;

int main(int argc, char *argv[])
{
    int socket_descriptor;
    int iter = 0;
    char buf[80];
    struct sockaddr_in6 address;

    bzero(&address, sizeof(address)); /* empty data structure */
    address.sin6_family = AF_INET6;

    inet_pton(AF_INET6, "2080::a6ba:dbff:fee4:8902", &address.sin6_addr);
    address.sin6_port = htons(port);

    socket_descriptor = socket(AF_INET6, SOCK_DGRAM, 0);

    for (iter = 0; iter <= 20; iter++)
    {
        sprintf(buf,"data packet with ID %d\n", iter);
        sendto(socket_descriptor,
                buf, sizeof(buf),
                0, (struct sockaddr *)&address, sizeof(address));
    }

    sprintf(buf, "stop\n");
    sendto(socket_descriptor,
            buf, sizeof(buf),
            0, (struct sockaddr *)&address, sizeof(address));

    close(socket_descriptor); 
    printf("Messages Sent, Terminating\n");
    exit (0);
}
